package org.wangp.business.order.test

import org.junit.Test
import org.junit.runner.RunWith
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import org.wangp.business.user.UserCenterApplication
import org.wangp.business.user.domain.UserDTO
import org.wangp.business.user.service.UserService
import javax.annotation.Resource

/**
 * @author wangpeng (๑•ᴗ•๑)
 * @since 2021/10/5 22:59
 */
@RunWith(SpringRunner::class)
@SpringBootTest(classes = [UserCenterApplication::class])
class UserTest {

	companion object {
		val log: Logger = LoggerFactory.getLogger(UserTest::class.java)
	}

	@Resource
	private lateinit var userService: UserService

	@Test
	fun searchUserTest() {
		log.info(userService.searchUser(UserDTO().apply {
			current = 1
			size = 20
		}).toString())
	}

	@Test
	fun addUser() {
		log.info(userService.addUser(UserDTO(username = "lueluelue", password = "1111111")).toString())
	}

	@Test
	fun editUser() {
		userService.searchUser(UserDTO().apply {
			current = 1
			size = 1
		}).data?.map { userService.editUser(it) }
	}

	/**
	 * es响应结果
	 * took 查询的实践
	 * time_out 查询是否超时
	 * _stards 数据的副本 多个节点时，数据会分到多个节点上存储
	 * hits 响应内容
	 * total 总数
	 */
	@Test
	fun searchUserEs() {
		val dto = UserDTO()
		dto.size = 5
		log.info(userService.searchUserEs(dto).toString())
	}
}
